Skip to content

wifi_manager: keep Wi-Fi awake with Bluetooth on, as without - #856

Merged
bdbarnett merged 1 commit into
mainfrom
wifi-awake-with-bluetooth
Nov 26, 2026
Merged

bdbarnett merged 1 commit into
mainfrom
wifi-awake-with-bluetooth

Conversation

@bdbarnett

@bdbarnett bdbarnett commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

wifi_manager.connect() turns Wi-Fi power saving off on a board with no battery, but it made an exception while Bluetooth runs, on the idea that Bluetooth needs Wi-Fi asleep to share the antenna. It doesn't: ESP-IDF's coexistence gives Wi-Fi and Bluetooth their own time slices, and with power saving off Wi-Fi still sleeps outside its own slice (ESP-IDF's Wi-Fi guide, under Modem-sleep). The exception kept a Bluetooth speaker's Wi-Fi asleep, so its own pages and WebREPL were slow or unreachable. This drops it. power_save() and set_power_save() are unchanged, and a remembered set_power_save(True) or a fitted battery still keeps power saving on.

On an Ai-Thinker ESP32 Audio Kit (classic ESP32, 4 MB) running Bluetooth Receiver with its screen served by RemoteDisplay, at -44 to -54 dBm, after a hard reset and 40 s idle, then a page load every 35 s from Windows and from Linux and 30 pings:

Page loads under 2 s Slowest Pings answered
Power saving on (main) 3 of 10 4 timed out at 20 s, the rest up to 11.3 s 5 of 30
This branch (pm 0) 10 of 10 1.9 s 30 of 30
This branch, a second boot 8 of 10 5.2 s 30 of 30

The open question was whether keeping Wi-Fi awake costs Bluetooth audio. A computer streamed a quiet 440 Hz tone to the board over A2DP (SBC, 48 kHz) for about 200 s in each mode, with the app's screen, the spectrum and the remote display running. With power saving on and with it off, the sink's counters showed no underruns, overruns, dropped, repeated or skipped frames, the audio pump never ran dry, and frames arrived at 48.0k a second. Four 0.9 s captures of the pump's output in each mode, taken with audiopump.Tap, are clean sines with no phase breaks.

tests/test_wifi_manager.py now has Bluetooth Classic and BLE both on and expects the station awake; it fails on main and passes here (66 Wi-Fi tests pass). Not checked: BLE on an S3 or C3 (the S31 had kept its link with BLE on and power saving off), CircuitPython on a board, and the page while music plays. During a stream the bench computer was itself the Bluetooth source, and its own Wi-Fi then lost 40% of its pings to the router, so the board's Wi-Fi during playback couldn't be judged from it.

A board on a cable now turns power saving off whether or not Bluetooth is
running. ESP-IDF's coexistence gives Wi-Fi and Bluetooth their own time
slices either way, and leaving Wi-Fi asleep made a Bluetooth speaker's own
page and WebREPL slow or unreachable.
@bdbarnett
bdbarnett merged commit 2367522 into main Nov 26, 2026
11 of 12 checks passed
@bdbarnett
bdbarnett deleted the wifi-awake-with-bluetooth branch November 26, 2026 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant